/**
 * 时间  ：2015-08-05
 * 功能  ：用于用户注册表单验证
 */
var registerValidator = function() {  

    var handleSubmit = function() {  

        $('#login_form').validate({

            errorElement : 'span',  

            errorClass : 'help-block',  
            
            onfocusout: function(element) { $(element).valid(); } ,

            rules : {  

                code: {
                	required:true,
                	 remote:{                                          //验证验证码
                         type:"POST",
                         async:false,async:false,
                         url:"/application/login/checkCode",
                         data:{
                             captcha:function(){return $("#code").val();}
                         } 
                       } 
                },

            },  

            messages : {
                code :  {
                	required:"请输入验证码",
                	remote:"请输入正确的验证码"
                },
            },  

            highlight : function(element) {  
                $(element).closest('#reg').addClass('error');  
            },  
            success : function(label) {  
                label.closest('#reg').removeClass('error');  
                label.remove();  
            },  

            errorPlacement : function(error, element) {  
                element.parent('div').append(error);  
            }
             ,  

             submitHandler : function(form) {  
                 if (!$('#reg').validate().form()) { 
                      return false;  
                  }
          			return true;
            }

        });  

    }  

    return {  
        init : function() {  
            handleSubmit();  
        }  

    };  

}(); 